#include <iostream>

class Color // 颜色
{
public:
    virtual void paint(const std::string &pentype, const std::string &name) = 0;
};

class Red : public Color
{
    void paint(const std::string &pentype, const std::string &name)
    {
        std::cout << pentype << "红色的" << name << std::endl;
    }
};

class Bule : public Color
{
    void paint(const std::string &pentype, const std::string &name)
    {
        std::cout << pentype << "蓝色的" << name << std::endl;
    }
};

class Pen
{
public:
    void SetColor(Color *c)
    {
        this->c = c;
    }
    virtual void Draw(const std::string &name) = 0;

protected:
    Color *c;
};

class pencil : public Pen
{
public:
    void Draw(const std::string &name)
    {
        this->c->paint("铅笔画", name);
    }
};
class smallpen : public Pen
{
public:
    void Draw(const std::string &name)
    {
        this->c->paint("毛笔画", name);
    }
};
int main()
{
    Pen *p1 = new pencil;
    Pen *p2 = new smallpen;

    Color *c1 = new Red;
    Color *c2 = new Bule;

    p1->SetColor(c1);
    p1->Draw("太阳");

    p2->SetColor(c2);
    p2->Draw("海洋");
    return 0;
}